package com.fjl;

import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import java.util.List;

public interface FileDocumentRepository extends ElasticsearchRepository<FileDocument, String> {
    List<FileDocument> findByContentContaining(String keyword);

    @Query("{\"match\": {\"content\": \"?0\"}}")
    List<FileDocument> findByContent(String content);

    @Query("{\"match\": {\"fileName\": \"?0\"}}")
    List<FileDocument> findByFileNameCustomQuery(String fileName);


    @Query("{\"multi_match\": {\"query\": \"?0\", \"fields\": [\"fileName\", \"content\", \"id\"]}}")
    List<FileDocument> searchAll(String key);

}
